﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using DevExpress.XtraEditors;
using DevExpress.XtraCharts;

namespace Client
{
    public partial class FormICSAChart : BasePopForm
    {
        QunYing.BLL.DeviceRealTimeInfo bll_drti = new QunYing.BLL.DeviceRealTimeInfo();
        public FormICSAChart()
        {
            InitializeComponent();
            this.Size = new Size(800,600);
            this.secondaryAxisY3.Range.MaxValue = 50;
            this.secondaryAxisY3.Range.MinValue = 0;
            this.secondaryAxisY4.Range.MaxValue = 14;
            this.secondaryAxisY4.Range.MinValue = 0;
            
        }
        private void BindData(DataTable dt)
        {
            DateTime temp = new DateTime();
            for (int i = 0; i < dt.Rows.Count;i++ )
            {
                DataRow v = dt.Rows[i];
                DateTime dateTime= (DateTime)(v["数据发送时间"]);
                if (dateTime.Year == temp.Year && dateTime.Month == temp.Month && dateTime.Day == temp.Day)
                {
                    continue;
                }
                else
                {
                    SeriesPoint seriesPoint = new SeriesPoint(dateTime, v["水族箱温度值"]);
                    this.series4.Points.Add(seriesPoint);
                    seriesPoint = new SeriesPoint(dateTime, v["水族箱PH值"]);
                    this.series5.Points.Add(seriesPoint);
                    seriesPoint = new SeriesPoint(dateTime, v["水族箱ORP值"]);
                    this.series6.Points.Add(seriesPoint);
                }
            }
            
        }

        public void BindData(QunYing.Model.ICSA_Device model)
        {
            this.lbl_设备ID.Text = model.ICSA设备ID;
            this.lbl_所属经销商.Text = model.所属经销商;
            this.lbl_所属会员卡号.Text = model.报警接收手机号码;
            DateTime dt = DateTime.Today.AddDays(-100);
            var vv = bll_drti.GetList(string.Format("发送号码='{0}' and 数据发送时间>'{1}' order by 数据发送时间 desc", model.通信号码, dt.ToString())).Tables[0];
            this.BindData(vv);
        }
    }
}